const modeAtom = atom<'edit' | 'view'>({
  key: 'mode',
  default: 'edit'
});

export const useMode = () => {
  const [mode, setMode] = useRecoilState(modeAtom);
  const toggleMode = () => {
    setMode((prev) => (prev === 'edit' ? 'view' : 'edit'));
  };
  
  return {
    mode,
    setMode,
    toggleMode
  };
};
